﻿using Microsoft.Extensions.Options;

using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;

namespace Utils.WeChat.Options
{
    public class WeChatOptions
    { 
        /// <summary>
        /// 商户号
        /// </summary>
        public string MerchantID { get; set; }

        public string SerialNo { get; set; }

        public string Key { get; set; }

        public string PrivateKey { get; set; }

        /// <summary>
        /// 退款证书路径
        /// </summary>
        public string CertPath { get; set; }

        /// <summary>
        /// 异步回调地址
        /// </summary>
        public string NotifyURL { get; set; }

        /// <summary>
        /// 退款回调地址
        /// </summary>
        public string RefundNotifyURL { get; set; }
         
        public X509Certificate2 GetCertificate() => new X509Certificate2(CertPath, MerchantID, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);

  
        public Dictionary<string, WeChatAppOptions> Apps { get; set; }
    }

    public class WeChatAppOptions
    {
        public string AppID { get; set; }

        public string AppSecret { get; set; }

        public Dictionary<string,string> TemplateCode { get; set; }
    }
}
